package informationretrieval;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;

/**
 * 
 * AllResultCounter.java - a class to save a result set per given query
 * 
 */
public class ResultSet {

	// Class variables
	HashMap<Integer, Vector<Integer>> mResults;
	Vector<Integer> mRankedDocumentList;

	/**
	 * Class constructor
	 */
	public ResultSet() {
		mResults = new HashMap<Integer, Vector<Integer>>();
	}

	/**
	 * Add a result to the result list
	 * 
	 * @param queryId
	 *            The query id
	 * @param docId
	 *            The document id
	 */
	public void AddResults(int queryId, int docId) {
		mRankedDocumentList = mResults.get(queryId);
		if(mRankedDocumentList == null) {
			mRankedDocumentList = new Vector<Integer>();
		}

		if (!mResults.containsKey(queryId)) {
			mResults.put(queryId, new Vector<Integer>());
		}

		mRankedDocumentList.add(docId);
	}
	
	/**
	 * A method to get the true result set
	 * @return The true rank result set (Id of the relevant documents)
	 */
	public List<Integer> getTrueRankList(int queryId) {
		ArrayList<Integer> relevantDocIds = new ArrayList<Integer>(mResults.get(queryId));
		return relevantDocIds;
	}

}